package com.lyf.viewapp.dialog.NiftyDialogEffects;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.gitonway.lee.niftymodaldialogeffects.lib.Effectstype;
import com.gitonway.lee.niftymodaldialogeffects.lib.NiftyDialogBuilder;
import com.lyf.viewapp.base.BaseActivity;
import com.lyf.viewapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class NiftyDialogEffectsActivity extends BaseActivity implements View.OnClickListener{

    @BindView(R.id.fadein)
    Button fadein;
    @BindView(R.id.slideright)
    Button slideright;
    @BindView(R.id.slideleft)
    Button slideleft;
    @BindView(R.id.slidetop)
    Button slidetop;
    @BindView(R.id.slideBottom)
    Button slideBottom;
    @BindView(R.id.newspager)
    Button newspager;
    @BindView(R.id.fall)
    Button fall;
    @BindView(R.id.sidefall)
    Button sidefall;
    @BindView(R.id.shake)
    Button shake;
    @BindView(R.id.fliph)
    Button fliph;
    @BindView(R.id.flipv)
    Button flipv;
    @BindView(R.id.rotatebottom)
    Button rotatebottom;
    @BindView(R.id.rotateleft)
    Button rotateleft;
    @BindView(R.id.slit)
    Button slit;
    private Effectstype effect;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog_plus);
        ButterKnife.bind(this);
        fadein.setOnClickListener(this);
        slideright.setOnClickListener(this);
        slideleft.setOnClickListener(this);
        slidetop.setOnClickListener(this);
        slideBottom.setOnClickListener(this);
        newspager.setOnClickListener(this);
        fall.setOnClickListener(this);
        sidefall.setOnClickListener(this);
        shake.setOnClickListener(this);
        fliph.setOnClickListener(this);
        flipv.setOnClickListener(this);
        rotatebottom.setOnClickListener(this);
        rotateleft.setOnClickListener(this);
        slit.setOnClickListener(this);
    }
    public void dialogShow(View v) {
        NiftyDialogBuilder dialogBuilder = NiftyDialogBuilder.getInstance(this);

        switch (v.getId()) {
            case R.id.fadein:
                effect = Effectstype.Fadein;
                break;
            case R.id.slideright:
                effect = Effectstype.Slideright;
                break;
            case R.id.slideleft:
                effect = Effectstype.Slideleft;
                break;
            case R.id.slidetop:
                effect = Effectstype.Slidetop;
                break;
            case R.id.slideBottom:
                effect = Effectstype.SlideBottom;
                break;
            case R.id.newspager:
                effect = Effectstype.Newspager;
                break;
            case R.id.fall:
                effect = Effectstype.Fall;
                break;
            case R.id.sidefall:
                effect = Effectstype.Sidefill;
                break;
            case R.id.fliph:
                effect = Effectstype.Fliph;
                break;
            case R.id.flipv:
                effect = Effectstype.Flipv;
                break;
            case R.id.rotatebottom:
                effect = Effectstype.RotateBottom;
                break;
            case R.id.rotateleft:
                effect = Effectstype.RotateLeft;
                break;
            case R.id.slit:
                effect = Effectstype.Slit;
                break;
            case R.id.shake:
                effect = Effectstype.Shake;
                break;
            default:
                break;
        }

        dialogBuilder
                .withTitle("Modal Dialog")                                  //.withTitle(null)  no title
                .withTitleColor("#FFFFFF")                                  //def
                .withDividerColor("#11000000")                              //def
                .withMessage("This is a modal Dialog.")                     //.withMessage(null)  no Msg
                .withMessageColor("#FFFFFFFF")                              //def  | withMessageColor(int resid)
                .withDialogColor("#FFE74C3C")                               //def  | withDialogColor(int resid)                               //def
                .withIcon(getResources().getDrawable(R.mipmap.ic_launcher))
                .isCancelableOnTouchOutside(true)                           //def    | isCancelable(true)
                .withDuration(700)                                          //def
                .withEffect(effect)                                         //def Effectstype.Slidetop
                .withButton1Text("OK")                                      //def gone
                .withButton2Text("Cancel")                                  //def gone
                .setCustomView(R.layout.nifty_dialog_effects_custom_view, v.getContext())         //.setCustomView(View or ResId,context)
                .setButton1Click(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(v.getContext(), "i'm btn1", Toast.LENGTH_SHORT).show();
                    }
                })
                .setButton2Click(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(v.getContext(), "i'm btn2", Toast.LENGTH_SHORT).show();
                    }
                })
                .show();

    }

    @Override
    public void onClick(View v) {
        dialogShow(v);
    }
}
